//
//  UIButton+Extension.swift
//  SinaWeibo
//
//  Created by 石林 on 15/11/20.
//  Copyright © 2015年 石林. All rights reserved.
//

import UIKit

extension UIButton {
    
    convenience init(title: String, backImage: String, color: UIColor?) {
    
        //在分类中,要使用便利的构造方法 convenience
        self.init()
        setTitle(title, forState: .Normal)
        setBackgroundImage(UIImage(named: backImage), forState: .Normal)
        setBackgroundImage(UIImage(named: backImage + "_highlighted"), forState: .Highlighted)
        if color != nil {
            
            setTitleColor(color, forState: .Normal)
            
        }
        
        
    }
    
}
